# 客户端和服务端相互发送数据
import socket

server_sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip_port = ("127.0.0.1", 8080)
server_sk.bind(ip_port)
server_sk.listen(128)
new_socket, addr = server_sk.accept()

# 先接受客户端发送过来的数据
ret = new_socket.recv(1024).decode('utf-8')
print('客户端发来贺电:', ret)

# 向客户端发送数据
new_socket.sendall('你好啊客户端'.encode('utf-8'))

new_socket.close()
server_sk.close()
